//TL_K!
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
 
using namespace std;
typedef long long ll;

int n, q, i, j, k, a[100001],b[30], l, r, s, x, p, NN;
char que[32], t, *yy;

void query(){
	//printf("query(%d,%d)\n",l,r);
	x=20000000;
	for(i=l;i<=r;++i){
		if(a[i]<x)x=a[i];
	}
	printf("%d\n", x);
}
void shift(){
	//printf("shift(%d", b[0]);for(i=1;i<s;++i)printf(",%d",b[i]);printf(") %d\n", s);
	
	//for(i=1;i<=n;++i)printf("%d", a[i]);printf("\n");
	x=a[b[0]];--s;
	for(i=0;i<s;++i){
		a[b[i]]=a[b[i+1]];
	}
	a[b[s]]=x;
}


int main(){
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	scanf("%d%d", &n, &q);
	for(i=1;i<=n;++i){
		scanf("%d", &a[i]);
	}
	for(k=0;k<q;++k){
		scanf("%s", que);
		if(que[0]=='q'){
			sscanf(que+6, "%d,%d", &l, &r);
			query();
		}
		else if(que[0]=='s'){
			s=0;
			p=6;
			NN = strlen(que);
			do{
				sscanf(que+p, "%d%c", &x, &t);
				b[s]=x;
				while(x/=10)++p;
				p+=2;
				++s;
			}while(p<NN );
			shift();
		}
	}
	
	return 0;
}
